import QtQuick 2.7
import QtQuick.Controls 2.5

import "./widgets" as Widgets
import "./layouts" as Layouts

Rectangle {
    id: root

    signal xx()
    signal requestShowConnectDevice()
    signal requestShowDetect()
    signal requestShowHistory()

    function setBoxConnectState(state) {
        //...
        if (1 === state) { //connected
            btnStep_1.enabled = false
            btnStep_2.enabled = true

            btnStep_1.text += qsTr("(已連接)")
        } else {
            btnStep_1.enabled = true
            btnStep_2.enabled = false
            btnStep_1.text = qsTr("步驟一：連接儀器")
        }
    }

    /////////////////////////////////////// UI ////
    Layouts.TopLayoutWithExit {
        id: toolBar
        z: 100
        width: parent.width
        height: root.height * 0.1
        visible: true
        canBack: false

        title: qsTr("HPY")
    }

    ///////////////////
    Item {
        width: parent.width
        height: parent.height - toolBar.height
        y: toolBar.height

        Column {
            width: parent.width
            anchors.centerIn: parent
            spacing: 6

            Widgets.LogoLayout {
                width: parent.width
                height: root.height * 0.15
            }

            Label {
                width: parent.width
                height: root.height * 0.15
                horizontalAlignment: Label.AlignHCenter
                verticalAlignment: Label.AlignVCenter

                text: qsTr("检测账号：") + g_currentUser
                font.pixelSize: height * 0.25
            }

            Widgets.DetectButton {
                id: btnStep_1
                width: parent.width
                height: root.height * 0.12

                text: qsTr("步驟一：連接儀器")
                onClicked: {
                    requestShowConnectDevice()
                }
            }

            Widgets.DetectButton {
                id: btnStep_2
                width: parent.width
                height: root.height * 0.12
                enabled: false

                text: qsTr("步驟二：開始檢測")
                onClicked: {
                    requestShowDetect()
                }
            }

            Widgets.DetectButton {
                id: btnStep_3
                width: parent.width
                height: root.height * 0.12

                text: qsTr("步驟三：查看報告")
                onClicked: {
                    requestShowHistory()
                }
            }
        }
    }
}
